package com.geekaca.iobuffer;

import java.io.*;

public class TestCharset {
    public static void main(String[] args) {


        try (InputStream is = new FileInputStream("studyIOBuffer\\writer.txt");
//             InputStreamReader isr = new InputStreamReader(is, "GB18030");
             // 转接
             InputStreamReader isr = new InputStreamReader(is, "GBK");
        ) {
            BufferedReader br = new BufferedReader(isr);
            String s = null;
            while ((s = br.readLine()) != null) {
                System.out.println(s);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        testInput();

    }

    public static void testInput(){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = null;
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("输入了: " +s);
    }


}
